from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import users, statistical
from .views import channels, skus, spus, orders

urlpatterns = [
    # 用户登录后台
    url(r'^authorizations/$', users.AdminAuthorizeView.as_view()),
    # 统计用户总数
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 统计日增长用户
    url(r'^statistical/day_increment/$', statistical.UserDayIncrementView.as_view()),
    # 统计日活用户
    url(r'^statistical/day_active/$', statistical.UserDayActiveView.as_view()),
    # 统计日下单用户
    url(r'^statistical/day_orders/$', statistical.UserDayOrdersView.as_view()),
    # 统计30日每日增长的用户数量
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 统计日商品分类访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),
    # 用户管理
    url(r'^users/$', users.UserInfoView.as_view()),
    # 频道管理——查询频道组数据
    url(r'^goods/channel_types/$', channels.ChannelTypesView.as_view()),
    # 频道管理——查询一级分类数据
    url(r'^goods/categories/$', channels.ChannelCategoriesView.as_view()),
    # 图片管理——获取简单SKU信息
    url(r'^skus/simple/$', skus.SKUSimpleView.as_view()),
    # 获取简单SPU信息
    url(r'^goods/simple/$', spus.SPUSimpleView.as_view()),
    # 获取某一SPU的规格和规格选项
    url(r'^goods/(?P<pk>\d+)/specs/$', spus.SPUSpecView.as_view()),
]

# 频道管理
router = DefaultRouter()
router.register('goods/channels', channels.ChannelViewSet, base_name='channels')
urlpatterns += router.urls
# 图片管理
router = DefaultRouter()
router.register(r'skus/images', skus.SKUImageViewSet, base_name='images')
urlpatterns += router.urls
# SKU商品管理
router = DefaultRouter()
router.register('skus', skus.SKUViewSet, base_name='skus')
urlpatterns += router.urls
# 订单管理
router = DefaultRouter()
router.register('orders', orders.OrdersViewSet, base_name='orders')
urlpatterns += router.urls
